package org.example.result;

import lombok.Data;

import java.io.Serializable;

@Data
public class Result implements Serializable {

    private Integer code;
    private String message;
    private Object data;

    public static Result success(Object data) {
        Result r = new Result();
        r.setData(data);
        r.setMessage(null);
        r.setCode(200);
        return r;
    }

    public static Result success() {
        Result r = new Result();
        r.setData(null);
        r.setMessage(null);
        r.setCode(200);
        return r;
    }

    public static Result error(Integer code, String msg) {
        Result r = new Result();
        r.setData(null);
        r.setMessage(msg);
        r.setCode(code);
        return r;
    }

}
